//
//  BDNavigationController.m
//  BeidouMall
//
//  Created by qie on 16/3/28.
//  Copyright © 2016年 qie. All rights reserved.
//

#import "BDNavigationController.h"
#import "BDOrderDetailViewController.h"
#import "BDOrderHomeViewController.h"

@interface BDNavigationController ()

@end

@implementation BDNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bg"] forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.translucent = NO;
    self.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:RGBColor(255, 255, 255) forKey:NSForegroundColorAttributeName];
    
    //    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"ShiShangZhongHei" size:16.0],NSFontAttributeName,nil]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    if (self.viewControllers.count > 0) {
        UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back4"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnClick)];
        viewController.navigationItem.leftBarButtonItem = barButtonItem;
        viewController.view.clipsToBounds = YES;
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:YES];
    
}

- (void)backBtnClick {
    if ([self.topViewController isKindOfClass:[BDOrderDetailViewController class]]) {
        BDOrderDetailViewController *orderDetail = (BDOrderDetailViewController *)self.topViewController;
        if (orderDetail.notRefreshHome) {
            for (UIViewController *vc in self.viewControllers) {
                if ([vc isKindOfClass:[BDOrderHomeViewController class]]) {
                    BDOrderHomeViewController *orderHome = (BDOrderHomeViewController *)vc;
                    orderHome.notRefreshHome = YES;
                }
            }
        }
    }
    [self popViewControllerAnimated:YES];
}

@end
